﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="action_edit.aspx.cs" Inherits="Donal.Xms.Web.qianyi.common.action_edit" ValidateRequest="false" %>

<%@ Import Namespace="Donal.Xms.Common" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>编辑活动</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <link rel="stylesheet" type="text/css" href="../../scripts/artdialog/ui-dialog.css" />
    <link rel="stylesheet" type="text/css" href="../skin/icon/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../skin/default/style.css" />
    <script type="text/javascript" charset="utf-8" src="../../scripts/jquery/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../scripts/jquery/Validform_v5.3.2_min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../scripts/artdialog/dialog-plus-min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../scripts/datepicker/WdatePicker.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/common.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/laymain.js"></script>
    <script src="../../scripts/jquery/jquery.cookie.js"></script>
    <script type="text/javascript">
        $(function () {
            //初始化表单验证
            $("#form1").initValidform();

            //创建选择优惠券窗体
            $(".spec-btn").click(function () {
                $.cookie("idc", null, { path: '/' });
                showSpecDialog();
            });

            //初始化选择优惠券窗口
            function showSpecDialog() {
                var d = top.dialog({
                    id: 'specDialogId',
                    padding: 0,
                    title: "选择优惠券",
                    url: 'dialog/dialog_select_coupons.aspx',
                    onclose: function () {
                        iniIdv();
                    }
                }).showModal();
                d.data = $("#item_box");
            }

            function initialization() {
                if ($("#hidConditions").val() == "1") {
                    $("#dlConditions").show();
                } else {
                    $("#dlConditions").hide();
                }

                if ($("#hidExpiration_form").val() == "1") {
                    $("#dlstart").hide();
                    $("#dlend").hide();
                } else {
                    $("#dlstart").show();
                    $("#dlend").show();
                }
            };


            $("[id$='cbConditions']").change(function () {
                if ($("#hidConditions").val() == "0") {
                    $("#hidConditions").val("1");
                    $("#dlConditions").show();
                } else {
                    $("#hidConditions").val("0");
                    $("#dlConditions").hide();
                    var v = $("[id$='txtConditions_amount']").val();

                    $("[id$='txtConditions_amount']").val(v == "" ? "0" : v);
                }
            });


            $("a").click(function () {
                var htmls = $(this).html();
                if (htmls == "自动过期" || htmls == "永不过期") {
                    switch (htmls) {
                        case "自动过期":
                            $("#dlstart").show();
                            $("#dlend").show();
                            break;
                        case "永不过期":
                            $("#dlstart").hide();
                            $("#dlend").hide();
                            break;
                    }
                }
            });

            initialization();
        });

        function changeNum(obj) {
            if ($(obj).val() == "") {
                $(obj).val("1");
                $(obj).siblings("[id^='hid_']").val("1");
            } else {
                $(obj).siblings("[id^='hid_']").val($(obj).val());
            }

            iniIdv();
        };

        function iniIdv() {
            var idv = "";
            $("[id^='hid_']").each(function () {
                var id = $(this).attr("id").replace("hid_", "");
                var v = $(this).val();
                idv += id + "_" + v + ",";
            });

            if (idv != "") {
                idv = idv.substring(0, idv.length - 1);
            }

            $.cookie("idv", idv, { path: '/' });

        };

        function delTr(obj) {
            $(obj).parent().parent().remove();
            iniIdv();
        };

    </script>
</head>

<body class="mainbody">
    <form id="form1" runat="server">
        <!--导航栏-->
        <div class="location">
            <a href="coupons_list.aspx" class="back"><i class="iconfont icon-up"></i><span>返回列表页</span></a>
            <a href="../center.aspx"><i class="iconfont icon-home"></i><span>首页</span></a>
            <i class="arrow iconfont icon-arrow-right"></i>
            <span>活动管理</span>
            <i class="arrow iconfont icon-arrow-right"></i>
            <span>编辑活动</span>
        </div>
        <div class="line10"></div>
        <!--/导航栏-->

        <!--活动-->
        <div id="floatHead" class="content-tab-wrap">
            <div class="content-tab">
                <div class="content-tab-ul-wrap">
                    <ul>
                        <li><a class="selected" href="javascript:;">编辑活动</a></li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="tab-content">
            <dl>
                <dt>活动名称</dt>
                <dd>
                    <asp:TextBox ID="txtTitle" runat="server" CssClass="input normal" Width="200" datatype="*2-50" sucmsg=" " />
                    <span class="Validform_checktip">*名称最多50个字符</span>
                </dd>
            </dl>
            <dl>
                <dt>启用</dt>
                <dd>
                    <div class="rule-single-checkbox">
                        <asp:CheckBox ID="cbStatus" runat="server" Checked="false" />
                    </div>
                    <span class="Validform_checktip">*启用后活动开始</span>
                </dd>
            </dl>
            <dl>
                <dt>活动形式</dt>
                <dd>
                    <div class="rule-multi-radio">
                        <asp:RadioButtonList ID="rbtCategory" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                            <asp:ListItem Value="0" Selected="True">充值活动</asp:ListItem>
                            <asp:ListItem Value="1">订单活动</asp:ListItem>
                            <asp:ListItem Value="2">全部</asp:ListItem>
                        </asp:RadioButtonList>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>设置门槛</dt>
                <dd>
                    <asp:TextBox ID="txtConditions_amount" runat="server" CssClass="input small" datatype="/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/" sucmsg=" ">0</asp:TextBox>
                    元                    
                    <span class="Validform_checktip">*当订单金额大于等于设定金额时,可参与活动。 </span>
                </dd>
            </dl>

            <dl>
                <dt>描述</dt>
                <dd>
                    <asp:TextBox ID="txtContents" runat="server" CssClass="input normal" Width="300" Height="100" TextMode="MultiLine" datatype="*5-500" sucmsg=" " />
                    <span class="Validform_checktip">*描述最多500个字符</span>
                </dd>
            </dl>
            <div>

                <dl>
                    <dt>赠送优惠券</dt>
                    <dd>
                        <a class="icon-btn add spec-btn"><span>设置优惠券</span></a>
                        <div class="table-container" style="padding-top: 10px;">
                            <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="82%">
                                <thead>
                                    <tr>
                                        <th width="10%">优惠券</th>
                                        <th width="10%">金额</th>
                                        <th width="10%">数量</th>
                                        <th width="10%">状态</th>
                                        <th>描述</th>
                                        <th width="10%">删除</th>
                                    </tr>
                                </thead>
                                <tbody id="item_box">
                                    <asp:Repeater ID="rptList" runat="server">
                                        <ItemTemplate>
                                            <tr>
                                                <td align="center">
                                                    <input type="hidden" name="hidCouponsId" value="<%# Eval("coupon_id") %>" />
                                                    <%# new Donal.Xms.BLL.coupons().GetValue(Utils.ObjToInt(Eval("coupon_id")),"title")%></td>
                                                <td align="center">
                                                    <%#new Donal.Xms.BLL.coupons().GetValue(Utils.ObjToInt(Eval("coupon_id")),"amount")%></td>
                                                <td align="center">                                                    
                                                    <input type="text" name="quantity" maxlength="2" class="td-input" value="<%#Eval("quantity")%>" onchange="changeNum(this);" onkeydown="return checkNumber(event);" />
                                                </td>
                                                <td align="center">
                                                    <%#new Donal.Xms.BLL.coupons().GetValue(Utils.ObjToInt(Eval("coupon_id")),"status").ToString()=="1"?"禁用":"正常"%></td>
                                                <td style="white-space: inherit; word-break: break-all;">
                                                    <%#new Donal.Xms.BLL.coupons().GetValue(Utils.ObjToInt(Eval("coupon_id")),"contents") %>
                                                </td>
                                                <td align="center">
                                                    <a style="color: blue; cursor: pointer;" onclick="delTr(this);">删除</a>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </tbody>
                            </table>
                        </div>
                    </dd>
                </dl>

            </div>

            <dl>
                <dt>失效形式</dt>
                <dd>
                    <input type="hidden" id="hidExpiration_form" value="<%=hidExpiration_form %>" />
                    <div class="rule-multi-radio">
                        <asp:RadioButtonList ID="cblExpiration_form" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                            <asp:ListItem Value="0" Selected="True">自动过期</asp:ListItem>
                            <asp:ListItem Value="1">永不过期</asp:ListItem>
                        </asp:RadioButtonList>
                    </div>
                </dd>
            </dl>

            <dl id="dlstart">
                <dt>开始日期</dt>
                <dd>
                    <asp:TextBox ID="txtStart_time" runat="server" CssClass="input rule-date-input" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" datatype="/^\d{4}\-\d{1,2}\-\d{1,2}$/" errormsg="请选择正确的日期" sucmsg=" " />
                    <asp:Label ID="div_Start_time_tip" runat="server" CssClass="Validform_checktip" />
                </dd>
            </dl>
            <dl id="dlend">
                <dt>结束日期</dt>
                <dd>
                    <asp:TextBox ID="txtEnd_time" runat="server" CssClass="input rule-date-input" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" datatype="/^\d{4}\-\d{1,2}\-\d{1,2}$/" errormsg="请选择正确的日期" sucmsg=" " />
                    <span class="Validform_checktip">*结束日期：在自动过期形式下起作用。</span>
                </dd>
            </dl>


            <dl>
                <dt>排序</dt>
                <dd>
                    <asp:TextBox ID="txtSort_id" runat="server" CssClass="input small" Width="200" datatype="n" sucmsg=" " Text="99" />
                    <asp:Label ID="div_Sort_id_tip" runat="server" CssClass="Validform_checktip" />
                </dd>
            </dl>
            
        </div>
        <!--/活动-->

        <!--工具栏-->
        <div class="page-footer">
            <div class="btn-wrap">
                <asp:Button ID="btnSubmit" runat="server" Text="提交保存" CssClass="btn" OnClick="btnSubmit_Click" />
                <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript: history.back(-1);" />
            </div>
        </div>
        <!--/工具栏-->

    </form>
</body>
</html>

